﻿import com.dmotiko.general.BaseClip;
import com.dmotiko.util.StringUtils;
import com.dmotiko.prune.*;
import flash.display.BitmapData;
import mx.transitions.easing.Strong;
import mx.transitions.Tween;
/**
 * ...
 * @author sminutoli
 */
class com.dmotiko.prune.MainNewItem
extends BaseClip
{
	private var mcPhoto:MovieClip;
	private var mcl:MovieClipLoader;
	private var txtTitle:TextField;
	private var loading:MovieClip;
	
	private function initClip():Void {
		
		mcl = new MovieClipLoader();
		mcl.addListener(this);
		mcPhoto = createEmptyMovieClip("mcPhoto", this.getNextHighestDepth());
		mcPhoto.createEmptyMovieClip("img", 1 );
		mcPhoto.createEmptyMovieClip("bitmap", 2 );
		
		mcPhoto.onRelease = function() {
			Site.getApp().setSection(SiteSections.NEWS);
		}
	}
	
	private function onLoadInit(target:MovieClip):Void {
		loading.gotoAndStop(1);
		loading._visible = false;
		target._visible = false;
				
        var bitmap:BitmapData = new BitmapData(
            target._width, 
            target._height, 
            true);

         mcPhoto.bitmap.attachBitmap(
            bitmap, 
            1,
            "auto", 
            true);

         bitmap.draw(target);
		 target._width = 168;
		 target._height = 103;
		 mcPhoto.bitmap._width = 168;
		 mcPhoto.bitmap._height = 103;
	}
	
	private function refreshData():Void {
		
		var sTitle:String = data.title;
		if (sTitle.length > 25 ) sTitle = sTitle.substr(0, 22) + "...";
		txtTitle.text = sTitle.toUpperCase();
				
		mcl.loadClip(data.src, mcPhoto.img);
				
		loading._visible = true;
		loading.gotoAndPlay(2);
	}
	
}